package com.ch.light.mybatis.pojo;

import com.ch.light.mybatis.DriverType;

/**
 * 描述：com.ch.light.mybatis.pojo
 *
 * @author 80002023
 *         2017/5/13.
 * @version 1.0
 * @since 1.8
 */
public class DataSourceCfg {

    private String driverClass;
    private String url;
    private String type;
    private String host;
    private Long port;
    private String dbName;
    private String username;
    private String password;

    public String getDriverClass() {
        return driverClass;
    }

    public void setDriverClass(String driverClass) {
        this.driverClass = driverClass;
    }

    public String getUrl() {
        if (url == null || "".equals(url.trim())) {
            switch (DriverType.fromCode(type)) {
                case MYSQL:
                    url = "jdbc:mysql://" + host + ":" + port + "/" + dbName + "?serverTimezone=UTC&characterEncoding=utf-8";
                    break;
            }
        }
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getHost() {
        return host;
    }

    public void setHost(String host) {
        this.host = host;
    }

    public Long getPort() {
        return port;
    }

    public void setPort(Long port) {
        this.port = port;
    }

    public String getDbName() {
        return dbName;
    }

    public void setDbName(String dbName) {
        this.dbName = dbName;
    }

}
